package com.eight.common.vo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 向文豪
 * @program: eight-education-parent
 * @description:
 * @date 2023/5/22 19:08
 */
@Data
@NoArgsConstructor
@Api(value = "统一的json返回对象")
public class Result {
    @ApiModelProperty(value = "状态码  200 成功  500 失败  401 权限不够 402 未登录")
    private Integer code;
    @ApiModelProperty(value = "响应信息")
    private String message;
    @ApiModelProperty(value = "响应数据")
    private Object data;

    public static Result success(){
        return new Result(200,"成功",null);
    }
    public static Result success(Object data){
        return new Result(200,"成功",data);
    }
    public static Result fail(){
        return new Result(500,"失败",null);
    }
    public static Result fail(Object data){
        return new Result(500,"失败",data);
    }

    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
}
